<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath() ;
	String authServerPath  =(String)request.getSession().getAttribute("authServerPath");
%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改密码</title>
<jsp:include page="../../import.jsp" flush="true" />
<script src="<%=path %>/resource/lib/watchPwd.js" type="text/javascript"></script>

</head>
<body class="iframeBody">
<div class="Wrapper">
            <form id="formSet1">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_100_auto">
	                    <div class="label">原密码</div>
	                    <div class="field">
	                        <input name="oldPwd" id="oldPwd" type="password" class="ui-password"value="" validate="{required:true,maxlength:20}"
								   data-watch-pwd="pwd1"	   onpaste="return false" oncontextmenu="return false" oncopy="return false" oncut="return false">
	                        <span class="requiredSymbol">*</span>
	                    </div>
	                </div>
                    <div class="fieldBox col_100_auto">
	                    <div class="label">新密码</div>
	                    <div class="field">
	                        <input name="newPwd" id="newPwd" type="password" class="ui-password" value="" validate="{required:true,minlength:8,maxlength:16}"
								   data-watch-pwd="pwd2"   onpaste="return false" oncontextmenu="return false" oncopy="return false" oncut="return false">
	                        <span class="requiredSymbol">*</span>
	                    </div>
	                </div>
                    <div class="fieldBox col_100_auto">
	                    <div class="label">确认密码</div>
	                    <div class="field">
	                        <input name="surePwd" id="surePwd" type="password" class="ui-password" value="" validate="{required:true,minlength:8,maxlength:16}"
								   data-watch-pwd="pwd3" onpaste="return false" oncontextmenu="return false" oncopy="return false" oncut="return false">
	                        <span class="requiredSymbol">*</span>
	                    </div>
	                </div>
					<div style="width: 340px;">密码需由大小写字母、数字、特殊符号组成，长度为8-16个字符</div>
				</div>
            </form>
</div>


<script type="text/javascript">
$(function(){
	createEye('<%=path %>');
	var formSet1 = $('#formSet1').ligerForm({
	        validate : true
	});
    SET_popupIframeHeight();
});
frameElement.dialog.onOk = function () {
    save(0);
}
frameElement.dialog.onCancel = function () {
    frameElement.dialog.close();
}

frameElement.dialog.onOkForIndex = function () {
    save(1);
}

function save(_flag){
	var form = liger.get("formSet1");
	if (!form.valid()) {
    	top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false; 
    }
	var newPwd = $("#newPwd").val();
	var surePwd = $("#surePwd").val();
	if(newPwd!=surePwd){
    	top.$.ligerDialog.SQalert({content: "两次输入密码不一致 " , SQ_type: "warning" });
    	return;
	}
	var data = form.getData();
	
	var wait_dialog;
	$.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: '<%=path%>/system/sysUsr/modifyPwd.do',
		beforeSend: function(){
	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 // frameElement.dialog.close();
				usrLoginOut();

			 }else{
				top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}

function usrLoginOut() {
	var _sysCd,_SQID;
	var cookies =$.cookie('webSQID');
	if(cookies){
		var split = cookies.split("_");
		if(2 === split.length){
			_sysCd = split[0];
			_SQID = split[1];
		}
	}
	$.ajax({
		type: 'get',
		headers: {
			sysCd: "11000",
			SQID: _SQID
		},
		url: <%=authServerPath%>+"/user/sysUsr/loginOut.do",
		success: function (msg) {
			if(msg.success == 1){
				$.cookie("liger-home-tab", "", {path:'/'});
				$.cookie("FL_SQID", "", {path:'/'});
				window.location.reload();
			}else{
				ligerDialogSuc(msg.info, 3000);
			}
		}
	});
}

</script>



</body>
</html>
